package Test;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2023-03-17
 * Time: 7:38
 */
public class Demo1 {
    // 冒泡排序 (从小到大排序)
    public static void BubbleSort(int[] array) {
        // 比较趟数
        for (int i = 0; i < array.length - 1; i++) {
            boolean flag = false; // 若该趟过后全部有序, 则下一次排序检查的时候没有交换则标记
            // 每一趟的比较次数
            for (int j = 0; j < array.length - 1 - i; j++) {
                if (array[j] > array[j + 1]) {
                    int tmp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = tmp;
                    flag = true;
                }
            }
            if (flag == false) {
                return;
            }
        }
    }

    // 寻找两个单身狗(一组数组中两个不同的数, 其余均出现两次)
    public static void dou_single(int[] array) {
        // 先进行分类 按照 先异或的结果分类

    }

    public static void main1(String[] args) {
        int[] array = new int[]{1, 3, 2, 4, 5};
        BubbleSort(array);
        System.out.println(Arrays.toString(array));
        int a = 26;
        System.out.println(Integer.highestOneBit(a));
        // 0 0 0 0 1 0 1 0
        // 0 0 0 1 1 0 1 0
        System.out.println(Integer.toBinaryString((10 ^ (-10))));
        System.out.println((10 ^ (-10)));
    }

    public static void main(String[] args) {
        int row = 3;
        int line = 3;
        int[][] array1 = new int[3][3];
//        System.out.println(Arrays.toString(array1));
//        System.out.println(Arrays.deepToString(array1));

        int[][] array2 = new int[3][];
        int[][] array3 = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

        int[][] array = new int[row][line];
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
//        System.out.println(Arrays.toString(array));
        /*int[][] array = new int[row][line];

        for (int[] arr : array) {
            for (int x : arr) {
                System.out.print(x+" ");
            }
            System.out.println();
        }*/
    }
}
